package com.leboncoin.bean;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name="searchitem")
public class SearchItemBean {

	@Id	
	String searchText;

	@OneToMany(cascade=CascadeType.ALL, mappedBy="searchItemBean")
	List<ClassifiedBean> searchResults = new ArrayList<ClassifiedBean>();
	String searchCategory; //'Ventes immobilieres' 'Voitures'
	@Column(name="avg_price")
	Long average;

	@Transient
	protected static Logger logger = Logger.getLogger(SearchItemBean.class.getName());	

	@Transient
	Integer priceMin;
	@Transient
	Integer priceMax;

	public enum LocationType {
		PUY_DE_DOME("Puy-de-Dôme"), DEP_VOISINS("Départements voisins"), AUVERGNE("Auvergne"), 
		FRANCE("Toute la France"), LISTE_CP("LISTE_CP");
		private LocationType(String name) {
			 this.name = name;
		}
		private final String name;
		public String toString() {
			 return name;
		}
	};
	@Transient
	LocationType searchLocation;
	
	@Transient
	List<String> zipCodes = new ArrayList<String>();
	@Transient
	List<String> checkBoxList = new ArrayList<String>();
	
	public String getSearchCategory() {
		return searchCategory;
	}
	public void setSearchCategory(String searchCategory) {
		this.searchCategory = searchCategory;
	}
	public String getSearchText() {
		return searchText;
	}
	public void setSearchText(String searchText) {
		this.searchText = searchText;
	}
	public Integer getPriceMin() {
		return priceMin;
	}
	public void setPriceMin(Integer priceMin) {
		this.priceMin = priceMin;
	}
	public Integer getPriceMax() {
		return priceMax;
	}
	public void setPriceMax(Integer priceMax) {
		this.priceMax = priceMax;
	}
	public LocationType getSearchLocation() {
		return searchLocation;
	}
	public void setSearchLocation(LocationType searchLocation) {
		this.searchLocation = searchLocation;
	}
	public List<String> getZipCodes() {
		return zipCodes;
	}
	public void setZipCodes(List<String> zipCodes) {
		this.zipCodes = zipCodes;
	}
	public List<ClassifiedBean> getSearchResults() {
		return searchResults;
	}
	public void setSearchResults(List<ClassifiedBean> searchResults) {
		this.searchResults = searchResults;
	}
	public List<String> getCheckBoxList() {
		return checkBoxList;
	}
	public void setCheckBoxList(List<String> checkBoxList) {
		this.checkBoxList = checkBoxList;
	}
	public Long getAverage() {
		return average;
	}
	public void setAverage(Long average) {
		this.average = average;
	}
	
	
}
